import { User, UserProfile } from '@/types/data'
import { profileAction } from '@/types/store'

/* eslint-disable camelcase */
type T = {
  user: User,
  profile: UserProfile
}
const initialState:T = {
  user: {},
  profile: {}
} as T

const profile = (state:T = initialState, action: profileAction) => {
  if (action.type === 'profile/getUser') {
    return { ...state, user: action.payload }
  } else if (action.type === 'profile/getUserProfile') {
    return { ...state, profile: action.payload }
  }
  return state
}

export default profile
